// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_FIN_ACCOUNTS_PAYABLE_ITEM
// * CreateDate    : 2011/9/19 10:34:52
// * Creater       : CodeSmith
// * LastChangeDate: 2011/9/19 10:34:52
// * LastChanger   : 2011/9/19 10:34:52
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Fin
{
/// <summary>
    /// FinAccountsPayableItem
    /// </summary>
    public partial class FinAccountsPayableItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objFinAccountsPayableItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static FinAccountsPayableItemEntity GetFinAccountsPayableItem(FinAccountsPayableItemEntity objFinAccountsPayableItemEntity)
        {
            return DataAccess.SelectSingle<FinAccountsPayableItemEntity>(objFinAccountsPayableItemEntity);
        }
        public static DataSet GetDataSetBypayableOrderID(string payableOrderId)
        {
            if (payableOrderId == null)
            {
                return null;
            }
            string sql = @"SELECT API.*,P.*, CONVERT(DECIMAL(18,2),API.INVOICE_PRICE * API.INVOICE_QTY) AS TOTAL_AMOUNT
                            FROM FIN_ACCOUNTS_PAYABLE_ITEM API
                            INNER JOIN INV_IMPORT_ITEM II ON II.IMPORT_ITEM_ID = API.IMPORT_ITEM_ID
                            LEFT JOIN MST_PRODUCT P ON P.PRODUCT_ID = II.PRODUCT_ID
                            WHERE API.PAYABLE_ORDER_ID = '" + payableOrderId + "'";
            return DataAccess.SelectDataSet(sql);
        }
        public static FinAccountsPayableItemEntity GetById(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            FinAccountsPayableItemEntity entity = new FinAccountsPayableItemEntity();
            entity.ItemId = id;
            return DataAccess.SelectSingle<FinAccountsPayableItemEntity>(entity);
        }
        public static List<FinAccountsPayableItemEntity> GetByPayableId(string payableId)
        {
            if (string.IsNullOrEmpty(payableId))
            {
                return null;
            }
            FinAccountsPayableItemEntity entity = new FinAccountsPayableItemEntity();
            entity.PayableOrderId = payableId;
            return DataAccess.Select<FinAccountsPayableItemEntity>(entity);
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objFinAccountsPayableItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertFinAccountsPayableItem(FinAccountsPayableItemEntity objFinAccountsPayableItemEntity)
        {
            return DataAccess.Insert(objFinAccountsPayableItemEntity);
        }

        public static bool InsertFinAccountsPayableItem(List<FinAccountsPayableItemEntity> objFinAccountsPayableItemEntityList)
        {
            return DataAccess.Insert(objFinAccountsPayableItemEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objFinAccountsPayableItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateFinAccountsPayableItem(FinAccountsPayableItemEntity objFinAccountsPayableItemEntity)
        {
            return DataAccess.Update(objFinAccountsPayableItemEntity);
        }

        public static bool UpdateFinAccountsPayableItem(List<FinAccountsPayableItemEntity> objFinAccountsPayableItemEntityList)
        {
            return DataAccess.Update<FinAccountsPayableItemEntity>(objFinAccountsPayableItemEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objFinAccountsPayableItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteFinAccountsPayableItem(FinAccountsPayableItemEntity objFinAccountsPayableItemEntity)
        {
            return DataAccess.Delete(objFinAccountsPayableItemEntity);
        }

        public static bool DeleteFinAccountsPayableItem(List<FinAccountsPayableItemEntity> objFinAccountsPayableItemEntityList)
        {
            return DataAccess.Delete<FinAccountsPayableItemEntity>(objFinAccountsPayableItemEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetFinAccountsPayableItemAll()
        {
            return DataAccess.SelectAllDataSet<FinAccountsPayableItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<FinAccountsPayableItemEntity> GetFinAccountsPayableItemAllList()
        {
            return DataAccess.SelectAll<FinAccountsPayableItemEntity>();
        }
        #endregion
	}
	
	
}	

